<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>分步表单</title>
    <link rel="stylesheet" href="__LIBS__/layui/css/layui.css"/>
    <link rel="stylesheet" href="__MODULE__/admin.css?v=317"/>
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style>
        [lay-filter="formStepsStep"] .layui-form-item {
            margin-bottom: 25px;
        }
    </style>
</head>
<body>
<!-- 正文开始 -->
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body" style="padding-top: 40px;">
            <!-- 分布表单开始 -->
            <div class="layui-tab layui-steps layui-steps-readonly" lay-filter="formStepsStep"
                 style="max-width: 650px;">
                <!-- 标题 -->
                <ul class="layui-tab-title">
                    <li class="layui-this">
                        <i class="layui-icon layui-icon-ok">1</i>
                        <span class="layui-steps-title">第一步</span>
                        <span class="layui-steps-content">填写转账信息</span>
                    </li>
                    <li>
                        <i class="layui-icon layui-icon-ok">2</i>
                        <span class="layui-steps-title">第二步</span>
                        <span class="layui-steps-content">确认转账信息</span>
                    </li>
                    <li>
                        <i class="layui-icon layui-icon-ok">3</i>
                        <span class="layui-steps-title">第三步</span>
                        <span class="layui-steps-content">转账成功</span>
                    </li>
                </ul>
                <div class="layui-tab-content">
                    <div class="layui-tab-item layui-show">
                        <!-- 表单一 -->
                        <form class="layui-form" style="max-width: 600px;margin: 0 auto;padding: 40px 30px 0 0;">
                            <input type="hidden" id="id" value="{$tixian.id}">
                            <div class="layui-form-item">
                                <label class="layui-form-label">付款账户:</label>
                                <div class="layui-input-block" style="margin-left: 0;float: left;width: 440px">
                                    <!--<select name="payAccount" lay-verType="tips" lay-verify="required" required>
                                        <option value="easyweb@vip.com">easyweb@vip.com</option>
                                    </select>-->
                                    <input name="paynumber" value="" placeholder="请输入付款账户"
                                           class="layui-input" lay-verType="tips" id="paynumber">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label layui-form-required">收款账户:</label>
                                <div class="layui-input-block" style="margin-left: 0;float: left;width: 440px">
                                    <input name="txnumber" value="{$tixian.txnumber}" placeholder="请输入收款账户"
                                           class="layui-input" lay-verType="tips" lay-verify="required" required id="txnumber">
                                </div>
                            </div>
                            <div class="layui-form-item layui-form-text">
                                <label class="layui-form-label layui-form-required">收款人:</label>
                                <div class="layui-input-block" style="margin-left: 0;float: left;width: 440px">
                                    <input name="realname" placeholder="请输入收款人姓名" value="{$user.realname}" class="layui-input"
                                           lay-verType="tips" lay-verify="required" required id="realname"/>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label layui-form-required">转账金额:</label>
                                <div class="layui-input-block" style="margin-left: 0;float: left;width: 440px">
                                    <input name="txnum" placeholder="请输入金额" value="{$tixian.txnum}" class="layui-input" type="number"
                                           lay-verType="tips" lay-verify="required" required id="txnum">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label layui-form-required">提现方式:</label>
                                <div class="layui-input-block" style="margin-left: 0;float: left;width: 440px">
                                    <input name="txtype" placeholder="请输入提现方式" value="{$tixian.txtype}" class="layui-input" type="text"
                                           lay-verType="tips" lay-verify="required" required id="txtype">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-input-block">
                                    <button class="layui-btn" lay-filter="formStepSubmit1" lay-submit>&emsp;下一步&emsp;
                                    </button>
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="layui-tab-item">
                        <!-- 表单二 -->
                        <form class="layui-form" style="max-width: 600px;margin: 0 auto;padding: 40px 30px 0 0;">
                            <div class="layui-form-item">
                                <label class="layui-form-label">付款账户:</label>
                                <div class="layui-form-mid layui-word-aux paynumber" style="margin-left: 0;float: left;width: 440px"></div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">收款账户:</label>
                                <div class="layui-form-mid layui-word-aux txnumber" style="margin-left: 0;float: left;width: 440px"></div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">收款方式:</label>
                                <div class="layui-form-mid layui-word-aux txtype" style="margin-left: 0;float: left;width: 440px"></div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">收款人姓名:</label>
                                <div class="layui-form-mid layui-word-aux realname" style="margin-left: 0;float: left;width: 440px"></div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">转账金额:</label>
                                <div class="layui-form-mid layui-word-aux" style="margin-left: 0;float: left;width: 440px">
                                    <span class="txnum" style="font-size: 18px;color: #333;"></span>（人民币<span class="daxie">伍佰元整</span>）
                                </div>
                            </div>
                            <!--<div class="layui-form-item">
                                <label class="layui-form-label layui-form-required">支付密码:</label>
                                <div class="layui-input-block" style="margin-left: 0;float: left;width: 440px">
                                    <input placeholder="请输入支付密码" value="123456" type="password"
                                           class="layui-input" lay-verify="required" required>
                                </div>
                            </div>-->
                            <div class="layui-form-item">
                                <div class="layui-input-block">
                                    <button type="button" class="layui-btn layui-btn-primary" data-steps="prev"> 上 一 步&nbsp;
                                    </button>
                                    <button class="layui-btn" lay-filter="formStepSubmit2" lay-submit>&emsp;提交&emsp;
                                    </button>
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="layui-tab-item text-center" style="padding-top: 40px;">
                        <!-- 表单三 -->
                        <i class="layui-icon layui-icon-ok layui-circle"
                           style="background: #52C41A;color: #fff;font-size:30px;font-weight:bold;padding: 20px;line-height: 80px;"></i>
                        <div style="font-size: 24px;color: #333;margin-top: 30px;">操作成功</div>
                        <!--<div style="font-size: 14px;color: #666;margin-top: 20px;">预计两小时到账</div>-->
                        <!--<div style="text-align: center;margin: 50px 0 25px 0;">
                            <button class="layui-btn" data-steps="next">再转一笔</button>
                            <button class="layui-btn layui-btn-primary">查看账单</button>
                        </div>-->
                    </div>
                </div>
            </div>
            <!-- //分布表单结束 -->
            <hr>
            <div style="padding: 10px 30px 20px 30px;">
                <h3>说明</h3><br>
                <h4>转账到支付宝账户</h4>
                <p class="layui-text">如果需要，这里可以放一些关于产品的常见问题说明。</p>
                <br><h4>转账到银行卡</h4>
                <p class="layui-text">如果需要，这里可以放一些关于产品的常见问题说明。</p>
            </div>
        </div>
    </div>
</div>

<!-- js部分 -->
<script type="text/javascript" src="__LIBS__/layui/layui.js"></script>
<script type="text/javascript" src="__NJS__/common.js?v=317"></script>
<script>


    layui.use(['layer', 'form', 'steps'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var steps = layui.steps;

        /* 表单一提交事件 */
        form.on('submit(formStepSubmit1)', function (data) {

            var paynumber = $('#paynumber').val();
            var txnumber = $('#txnumber').val();
            var realname = $('#realname').val();
            var txnum = $('#txnum').val();
            var txtype = $('#txtype').val();
            var daxie = convertCurrency(txnum);
            //console.log(daxie);
            if(paynumber == ""){
                $('.paynumber').html('暂无');
            }else{
                $('.paynumber').html(paynumber);
            }
            $('.txnumber').html(txnumber);
            $('.realname').html(realname);
            $('.txnum').html(txnum);
            $('.txtype').html(txtype);
            $('.daxie').html(daxie);


            steps.next('formStepsStep');
            return false;
        });

        /* 表单二提交事件 */
        form.on('submit(formStepSubmit2)', function (data) {
            var id = $('#id').val();
            var paynumber = $('#paynumber').val();
            var txnumber = $('#txnumber').val();
            var realname = $('#realname').val();
            var txnum = $('#txnum').val();
            var txtype = $('#txtype').val();
            $.ajax({
                url:"{:url('txcz')}",
                type:'POST',
                dataType:'json',
                data: {id:id,paynumber:paynumber,txnumber:txnumber,realname:realname,txnum:txnum,txtype:txtype},
                success:function(res){
                    console.log(res)
                    if (res.code == 0) {
                        steps.next('formStepsStep');
                        return false;
                        /*layer.msg(res.msg,{icon:1,time:1500,shade:0.1})
                        setTimeout(function () {
                            admin.closeThisTabs();
                        }, 1000);*/
                    } else {
                        $(".layui-btn").removeClass('layui-disabled').removeAttr('disabled');
                        wk.error(res.msg);
                        return false;
                    }
                }
            })

            return false;
        });

    });

    function convertCurrency(money) {
        //汉字的数字
        var cnNums = new Array('零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖');
        //基本单位
        var cnIntRadice = new Array('', '拾', '佰', '仟');
        //对应整数部分扩展单位
        var cnIntUnits = new Array('', '万', '亿', '兆');
        //对应小数部分单位
        var cnDecUnits = new Array('角', '分', '毫', '厘');
        //整数金额时后面跟的字符
        var cnInteger = '整';
        //整型完以后的单位
        var cnIntLast = '元';
        //最大处理的数字
        var maxNum = 999999999999999.9999;
        //金额整数部分
        var integerNum;
        //金额小数部分
        var decimalNum;
        //输出的中文金额字符串
        var chineseStr = '';
        //分离金额后用的数组，预定义
        var parts;
        if (money == '') { return ''; }
        money = parseFloat(money);
        if (money >= maxNum) {
            //超出最大处理数字
            return '';
        }
        if (money == 0) {
            chineseStr = cnNums[0] + cnIntLast + cnInteger;
            return chineseStr;
        }
        //转换为字符串
        money = money.toString();
        if (money.indexOf('.') == -1) {
            integerNum = money;
            decimalNum = '';
        } else {
            parts = money.split('.');
            integerNum = parts[0];
            decimalNum = parts[1].substr(0, 4);
        }
        //获取整型部分转换
        if (parseInt(integerNum, 10) > 0) {
            var zeroCount = 0;
            var IntLen = integerNum.length;
            for (var i = 0; i < IntLen; i++) {
                var n = integerNum.substr(i, 1);
                var p = IntLen - i - 1;
                var q = p / 4;
                var m = p % 4;
                if (n == '0') {
                    zeroCount++;
                } else {
                    if (zeroCount > 0) {
                        chineseStr += cnNums[0];
                    }
                    //归零
                    zeroCount = 0;
                    chineseStr += cnNums[parseInt(n)] + cnIntRadice[m];
                }
                if (m == 0 && zeroCount < 4) {
                    chineseStr += cnIntUnits[q];
                }
            }
            chineseStr += cnIntLast;
        }
        //小数部分
        if (decimalNum != '') {
            var decLen = decimalNum.length;
            for (var i = 0; i < decLen; i++) {
                var n = decimalNum.substr(i, 1);
                if (n != '0') {
                    chineseStr += cnNums[Number(n)] + cnDecUnits[i];
                }
            }
        }
        if (chineseStr == '') {
            chineseStr += cnNums[0] + cnIntLast + cnInteger;
        } else if (decimalNum == '') {
            chineseStr += cnInteger;
        }
        return chineseStr;
    }
</script>
</body>
</html>